<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="div1"><p>p1</p></div>
    <button onclick="getText()">获取innerText</button>
    <button onclick="getHTML()">获取innerHTML</button>

    <button onclick="setText()">设置innerText</button>
    <button onclick="setHTML()">设置innerHTML</button>
    <script>
        let div = document.querySelector("#div1");

        function getText() {
            console.log(div.innerText);
        }

        function getHTML() {
            console.log(div.innerHTML);
        }

        function setText() {
            div.innerText = "<p>p2</p>";
        }

        function setHTML() {
            div.innerHTML = "<p>这是<mark>p2</mark></p>";
        }
        
    </script>
</body>
</html>